#include<stdio.h>
#include <malloc.h>
int main()
{
	int n;
	scanf_s("%d", &n);
	int* p = (int*)malloc(n * sizeof(int));
	int out = 0;
	int a = 1;
	for (int i = 1; i <= n; i++)
	{
		p[i - 1] = i;
	}
	int i = 0;
	while (out != n - 1) {
		if (p[i] == -1)
		{
			if (i == n - 1)
				i = 0;
			else
				i++;
			continue;
		}
		if (a == 3)
		{
			p[i] = -1;
			out++;
			a = 1;
			if (i == n - 1)
				i = 0;
			else
				i++;
			continue;
		}
		a++;
		if (i == n - 1)
			i = 0;
		else
			i++;

	}
	i = 0;
	while (p[i] == -1)
		i++;
	free(p);
	p = NULL;
	printf("%d", i + 1);
	return 0;
}
